package agile.tools.autotest.serializer.impl;

import agile.tools.autotest.serializer.Serializer;
import flexjson.JSONDeserializer;
import flexjson.JSONSerializer;

public class FlexJsonSerializer implements Serializer {

	public Object serialize(Object inputObject) {
		return serializer.deepSerialize(inputObject);
	}

	private static JSONSerializer serializer;
	private static JSONDeserializer deserializer = new JSONDeserializer();
	static {
		serializer = new JSONSerializer();
		serializer.prettyPrint(true);

		deserializer = new JSONDeserializer();
	}

	public String serializeAsString(Object inputObject) {
		return serialize(inputObject).toString();
	}

	public Object deSerialize(Object serializedInput) {
		return deserializer.deserialize(serializedInput.toString());
	}
}